﻿using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPISelfHostDemo.Model;

namespace WebAPISelfHostDemo.Controller
{
    public class ValuesController : ApiController
    {
        private Product[] products = new Product[]
        {
            new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 },
            new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M },
            new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M }
        };

        public void Post()
        {
        }

        //public HttpResponseMessage Get()
        //{
        //    HttpResponseMessage res = Request.CreateResponse(HttpStatusCode.OK, "value");
        //    res.Content = new StringContent("hello", Encoding.Unicode);
        //    res.Headers.CacheControl = new CacheControlHeaderValue() { MaxAge = TimeSpan.FromMinutes(20) };

        //    return res;
        //}

        public HttpResponseMessage Get1()
        {
            // Write the list to the response body.
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, products);
            return response;
        }
    }
}